{# A route's request, from its OpenAPI operation, as FastAPI's /docs shows it: ``mode`` "try" sends it once (Execute), "load" starts a load test of it. One form for Routes and Load Tests. #} {% from "components/macros/form.html" import field, number_input, select, text_input, textarea, checkbox, primary_button, action %}
{% if op.summary %}

{{ op.summary }}

{% endif %} {% if op.description %}

{{ op.description }}

{% endif %} {% if fields %}
{% for f in fields %} {% set p = f.param %}
{% call field(p.name ~ (" *" if p.required else "") ~ " (" ~ p.location ~ ", " ~ p.kind ~ ")") %} {% if f.options %}{{ select(p.field, f.options, selected=f.value, blank=None if p.required else "", block=True) }} {% elif p.kind in ("integer", "number") %}{{ number_input(p.field, f.value, step=1 if p.kind == "integer" else "any", required=p.required) }} {% else %}{{ text_input(p.field, f.value, required=p.required) }}{% endif %} {% endcall %} {% if p.description %}

{{ p.description }}

{% endif %}
{% endfor %}
{% endif %} {% if op.body_example is not none %} {% call field("Body, JSON" ~ (" *" if op.body_required else "")) %}{{ textarea("body", body, rows=8) }}{% endcall %} {% endif %}
{% call field("Sign in as") %}{{ select("role", roles, selected=role, blank=None, block=True) }}{% endcall %} {% if mode == "load" %} {% call field("Requests") %}{{ number_input("requests", requests, min=1, max=max_requests) }}{% endcall %} {% call field("Clients") %}{{ number_input("clients", clients, min=1, max=max_clients) }}{% endcall %} {% endif %}
{% if op.writes %}{{ checkbox("confirm", label=op.method ~ " changes data: send it anyway") }}{% endif %} {% if op.responses %}

Responses: {% for code, description in op.responses %}{{ code }} {{ description }}{{ ", " if not loop.last }}{% endfor %}

{% endif %}
{% if mode == "load" %} {{ primary_button("Start", "submit") }} {% else %} {{ primary_button("Execute", "submit") }} {{ action("Load test this", load_test_this) }} {% endif %}
{% if mode != "load" %}
{% endif %}